<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>高清无码管理系统</title>
    <link rel="stylesheet" href="../layui-v2.6.8/layui/css/layui.css">
</head>

<body>
    <div class="layui-layout layui-layout-admin">
        <!-- 引入公共页面 -->
        {{include "./common/header.html" }}
        <!-- 引入公共页面 -->
        {{include "./common/side_menu.html" }}



        <div class="layui-body" >
            <!-- 内容主体区域 -->
            <div style="padding: 15px;">
                <span class="layui-breadcrumb" lay-separator=">">
                    <a href="/">首页</a>
                    <a href="/addCate">分类添加</a>
                </span>
                <form style="padding: 15px; " class="layui-form" id="theform">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类名称： </label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="name" autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-form-item ">
                        <label class="layui-form-label "> 是否显示： </label>
                        <div class="layui-input-block">
                            <input type="radio" name="isshow" value='1' title="显示" checked="checked">
                            <input type="radio" name="isshow" value='0' title="不显示">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label > 内容： </label>
                        <div id="demo">
                           
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <!-- <button class="layui-btn layui-btn-normal">添加</button> -->
                            <input type="button" id="add" class="layui-btn layui-btn-normal" value="添加">
                        </div>
                    </div>
            </div>
            </form>
        </div>
    </div>


    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/layui/2.6.8/layui.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>
   <script>
            // 初始化富文本编辑器
            const E = window.wangEditor
        const editor = new E('#demo')
        editor.config.uploadImgShowBase64 = true
        // 或者 const editor = new E( document.getElementById('div1') )
        editor.create()
        //JS 
        layui.use(['element', 'layer', 'util'], function () {
            var element = layui.element
                , layer = layui.layer
                , util = layui.util
                , $ = layui.$;

            //头部事件
            util.event('lay-header-event', {
                //左侧菜单事件
                menuLeft: function (othis) {
                    layer.msg('展开左侧菜单的操作111', { icon: 0 });
                }
                , menuRight: function () {
                    layer.open({
                        type: 1
                        , content: '<div style="padding: 15px;">处理右侧面板的操作234</div>'
                        , area: ['260px', '100%']
                        , offset: 'rt' //右上角
                        , anim: 5
                        , shadeClose: true
                    });
                }
            });

        });

        // 添加分类
        $("#add").click(function () {
            $.ajax({
                type: "post",
                url: "/ajaxAddCate",
                data: new FormData($("#theform")[0]),
                processData: false,
                contentType: false,  
            }).then(({ errcode,message }) => {
                layer.msg(message)
                if(errcode === 200){
                    location.href="/classify-list"
                }
            })
        })

    </script>
</body>

</html>